Add color space detection and conversion for iPhone videos#1
Open
Geddart wants to merge 2 commits intoReflct:masterfrom
Open
Add color space detection and conversion for iPhone videos#1Geddart wants to merge 2 commits intoReflct:masterfrom
Geddart wants to merge 2 commits intoReflct:masterfrom
Conversation
iPhones record video in Display P3, BT.2020, or HDR (HLG/Dolby Vision), but sharp_frames extracted frames without any color space conversion, resulting in incorrect colors. This commit adds: - New colorspace.py module for detecting video color space via ffprobe - Automatic conversion to sRGB/BT.709 for wide gamut SDR content - HDR to SDR tone mapping using Hable algorithm (via zscale filter) - Graceful fallback when zscale is unavailable The fix applies to all three extraction code paths: - FrameExtractor (new modular extractor) - SharpFrames processor (legacy) - MinimalProgressSharpFrames (TUI) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes: - Remove unused List import from colorspace.py - Add __all__ export list for clear public API - Fix type hint: Optional[Any] -> Optional['VideoColorInfo'] - HDR filter now explicitly specifies input transfer/primaries/matrix for more reliable conversion - Optimize ffprobe calls: extract color info from existing video_info instead of making a separate subprocess call - Add parse_color_info_from_stream() as public API for reuse Tests: - Add comprehensive unit tests for colorspace module - Test VideoColorInfo.needs_conversion for all color space types - Test parse_color_info_from_stream with various ffprobe outputs - Test build_colorspace_filter for SDR, wide gamut, and HDR - Test zscale availability detection - Mock subprocess calls for isolated testing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
iPhones record video in Display P3, BT.2020, or HDR (HLG/Dolby Vision), but sharp_frames extracted frames without any color space conversion, resulting in incorrect colors.
This commit adds:
The fix applies to all three extraction code paths: